import java.util.Scanner;
import java.util.Random;

public class test_random {
    public static void main(String[] args) {
        Random random = new Random();
        int targetNumber = random.nextInt(100) + 1; // 生成1到100之间的随机数
        Scanner scanner = new Scanner(System.in);
        int guess;

        System.out.println("我已经生成了一个介于1到100之间的随机数，请猜测它是多少？");

        do {
            System.out.print("请输入你的猜测：");
            guess = scanner.nextInt();

            if (guess > targetNumber) {
                System.out.println("你猜测的数字过大了，请尝试更小的数字。");
            } else if (guess < targetNumber) {
                System.out.println("你猜测的数字过小了，请尝试更大的数字。");
            } else {
                System.out.println("恭喜你猜中了！随机数是 " + targetNumber);
            }
        } while (guess != targetNumber);

        scanner.close();
    }
}
